<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html class="win-frame">
<head>
<title>${name_china}管理-编辑${name_china}</title>
<%@include file="/common/head.jsp" %>

</head>
<body class="iframe-page">
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="page-title-text">
            <span>${name_china}管理</span>
            <span class="split"></span>
            <span>编辑${name_china}</span>
        </div>
        <a id="goBack" class="btn-return distance-left" href="javascript:;"><i class="icon icon-arrow-left"></i>返回上级</a>
    </div>
    <div class="page-title-border"></div>
</div>

<form id="form" method="post">
    <div class="form-wrapper">
	  <div class="h4 distance-double">
        <span class="h4-title"><i class="icon icon-setting"></i>基本信息</span>
        <span class="h4-border"></span>
      </div>
      
      <input type="hidden" id="id" name="id"/> 
      
      <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>标题</p>
	        <input type="text" id="title" name="title" class="summer-input summer-validatebox"  data-validatebox="validType:['required','maxLength[500]']"/> 
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>类型</p>
	        <input type="text" id="bugType" name="bugType" class="summer-input summer-validatebox"  data-validatebox="validType:['required','maxLength[255]']"/> 
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>指派给谁</p>
	        <input type="text" id="toUser" name="toUser" class="summer-input" data-validatebox="validType:['required','maxLength[255]']"/> 
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>BUG状态</p>
	        <input type="text" id="status" name="status" class="summer-input" data-validatebox="validType:['required','maxLength[255]']"/> 
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title">选择图片</p>
	        <input type="text" id="filePlugin" name="filePlugin" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[255]']"/> 
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title">复现步骤</p>
	        <textarea class="ckeditor" id="recurrent" name="recurrent"></textarea>
	     </div>
	     
	        <div class="form-cont">
	        <p class="form-cont-title">期望效果</p>
	        <textarea class="summer-textarea" id="wish" name="wish"></textarea>
	     </div>
	      
	      <div class="form-cont">
	        <p class="form-cont-title">为什么出现</p>
	        <textarea class="summer-textarea" id="note" name="note" data-validatebox="validType:['maxLength[1000]']"></textarea>
	     </div>
	
     
     <div class="form-btn-wrapper" id="funcbar">
        <a class="btn btn-normal" id="backBtn">关闭</a>
    </div>
  </div>
</form>
<script>
    
  var   editData,
        permission = CommonUtil.getPermission('${name_english}');
    
    $(function () {
    	editData = ${editData};
    	//初始化funcbar
     	$('#funcbar').prepend($.funcbar({
            type: 'button',
            data: permission,
            permit: ['${name_english}:edit']
        }));
    	//初始化下拉选项
    	$('#bugType').combobox({
    		defaultValue: editData.bugType,
    		async:false,
            valueField : 'code',
            textField : 'name',
            url : COMMON_URL.getCode + '?type=T_DM_T_DEVELOP_BUG_BUG_TYPE'
        });
    	//初始化下拉选项
    	$('#toUser').combobox({
    		defaultValue: editData.toUser,
    		async:false,
            valueField : 'id',
            textField : 'realname',
            url : CONST_URL.TO_USER_LIST
        });
    	//初始化下拉选项
    	$('#status').combobox({
    		defaultValue: editData.status,
    		async:false,
            valueField : 'code',
            textField : 'name',
            url : COMMON_URL.getCode + '?type=T_DM_T_DEVELOP_BUG_STATUS'
        });
	   	
        $('#form').form().form('loadDataEdit', {
            data: editData
        }); 
    	
        $("#filePlugin").filePlugin();
    	
    	//保存按钮
    	$('#funcbar').on('click', 'a[data-permit="${name_english}:edit"]', submit);
    	
    	//返回按钮
    	$('#backBtn, #goBack').on('click',backMain);
    });
    
    
    
    //表单提交
    function submit() {
         $("#form").form({
        	 buttons : ['#saveBtn'],
             ajax: {
                 url: CONST_URL.EDIT
             },
             onSubmitSuccess: function (data) {
            	 $.stip({
   	                type:'ok',//显示类型 有info、 ok、 danger
   	                text: '保存成功！',
   	                onBeforeHide: function () {
   	                	backMain();
   	                }
            	 });
              }
         }).form("submit");
    }
    
    //返回主页面
    function backMain() {
    	window.location.href = CONST_URL.INIT_MAIN;
    }
    
    //请求url
    var CONST_URL = {
    	INIT_MAIN: basePath + "${common_url}init",
    	TO_USER_LIST: basePath + "${common_url}toUserList",
       	EDIT: basePath + "${common_url}edit"
    };
    
</script>
</body>
</html>